import { request } from "../../request/index.js"
import regeneratorRuntime from '../../lib/runtime/runtime'
import { login } from "../../utils/asyncWx.js"
Page({
  // 点击授权
  async handleGetUserInfo(e) {
    console.log(e)
    try {
      // 1. 获取用户信息
      let { encryptedData, rawData, iv, signature } = e.detail
      // 2. 获取登录之后的值
      let { code } = await login()
      console.log(code)
      let loginParams = { encryptedData, rawData, iv, signature, code }
      console.log(loginParams)
      // 3. 发送请求
      // let res = await request({url:"/users/wxlogin",data:loginParams,method:"post"})
      // console.log(res)
      wx.setStorageSync("token", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjIzLCJpYXQiOjE1NjQ3MzAwNzksImV4cCI6MTAwMTU2NDczMDA3OH0.YPt-XeLnjV-_1ITaXGY2FhxmCe4NvXuRnRB8OMCfnPo");
      wx.navigateBack({
        delta: 1
      });
    } catch (err) {
      console.log(err)
    }
  }
})